/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_ABILITY_RUNTIME_CJ_BUNDLE_INFO_H
#define OHOS_ABILITY_RUNTIME_CJ_BUNDLE_INFO_H

#include "cj_utils_ffi.h"

namespace Keels {
namespace AbilityRuntime {
namespace Platform {
struct RetMetadata {
    char* name;
    char* value;
    char* resource;

    RetMetadata() : name(nullptr), value(nullptr), resource(nullptr) {}
};

struct CArrMetadata {
    RetMetadata* head;
    int64_t size;

    CArrMetadata() : head(nullptr), size(0) {}
};

struct ModuleMetadata {
    char* moduleName;
    CArrMetadata metadata;

    ModuleMetadata() : moduleName(nullptr), metadata() {}
};

struct CArrMoMeta {
    ModuleMetadata* head;
    int64_t size;

    CArrMoMeta() : head(nullptr), size(0) {}
};

struct CResource {
    char* bundleName;
    char* moduleName;
    uint32_t id;

    CResource() : bundleName(nullptr), moduleName(nullptr), id(0) {}
};

struct MultiAppMode {
    uint8_t multiAppModeType;
    int32_t count;

    MultiAppMode() : multiAppModeType(0), count(0) {}
};

struct RetApplicationInfoV2 {
    char* name;
    char* description;
    uint32_t descriptionId;
    bool enabled;
    char* label;
    uint32_t labelId;
    char* icon;
    uint32_t iconId;
    char* process;
    CArrString permissions;
    char* codePath;
    CArrMoMeta metadataArray;
    bool removable;
    uint32_t accessTokenId;
    int32_t uid;
    CResource iconResource;
    CResource labelResource;
    CResource descriptionResource;
    char* appDistributionType;
    char* appProvisionType;
    bool systemApp;
    int32_t bundleType;
    bool debug;
    bool dataUnclearable;
    bool cloudFileSyncEnabled;
    char* nativeLibraryPath;
    MultiAppMode multiAppMode;
    int32_t appIndex;
    char* installSource;
    char* releaseType;

    RetApplicationInfoV2()
        : name(nullptr), description(nullptr), descriptionId(0), enabled(true), label(nullptr), labelId(0),
          icon(nullptr), iconId(0), process(nullptr), codePath(nullptr), removable(false), accessTokenId(0), uid(-1),
          appDistributionType(nullptr), appProvisionType(nullptr), systemApp(false), bundleType(0), debug(false),
          dataUnclearable(false), cloudFileSyncEnabled(false), nativeLibraryPath(nullptr), appIndex(0),
          installSource(nullptr), releaseType(nullptr)
    {}
};

struct CArrInt32 {
    int32_t* head;
    int64_t size;

    CArrInt32() : head(nullptr), size(0) {}
};

struct RetWindowSize {
    double maxWindowRatio;
    double minWindowRatio;
    uint32_t maxWindowWidth;
    uint32_t minWindowWidth;
    uint32_t maxWindowHeight;
    uint32_t minWindowHeight;
};

struct RetSkillUri {
    char* scheme;
    char* host;
    char* port;
    char* path;
    char* pathStartWith;
    char* pathRegex;
    char* type;
    char* utd;
    int32_t maxFileSupported;
    char* linkFeature;

    RetSkillUri()
        : scheme(nullptr), host(nullptr), port(nullptr), path(nullptr), pathStartWith(nullptr), pathRegex(nullptr),
          type(nullptr), utd(nullptr), maxFileSupported(0), linkFeature(nullptr)
    {}
};

struct RetCArrSkillUri {
    RetSkillUri* head;
    int64_t size;

    RetCArrSkillUri() : head(nullptr), size(0) {}
};

struct RetSkill {
    CArrString actions;
    CArrString entities;
    RetCArrSkillUri uris;
    bool domainVerify;
};

struct RetCArrSkill {
    RetSkill* head;
    int64_t size;

    RetCArrSkill() : head(nullptr), size(0) {}
};

struct RetAbilityInfoV2 {
    char* bundleName;
    char* moduleName;
    char* name;
    char* label;
    uint32_t labelId;
    char* description;
    uint32_t descriptionId;
    char* icon;
    uint32_t iconId;
    char* process;
    bool exported;
    int32_t orientation;
    int32_t launchType;
    CArrString permissions;
    CArrString deviceTypes;
    RetApplicationInfoV2 applicationInfo;
    CArrMetadata metadata;
    bool enabled;
    CArrInt32 supportWindowModes;
    RetWindowSize windowSize;
    bool excludeFromDock;
    RetCArrSkill skills;
    int32_t appIndex;

    RetAbilityInfoV2()
        : bundleName(nullptr), moduleName(nullptr), name(nullptr), label(nullptr), labelId(0), description(nullptr),
          descriptionId(0), icon(nullptr), iconId(0), process(nullptr), exported(false), orientation(0), launchType(0),
          enabled(true), excludeFromDock(false), appIndex(0)
    {}
};

struct CArrRetAbilityInfoV2 {
    RetAbilityInfoV2* head;
    int64_t size;

    CArrRetAbilityInfoV2() : head(nullptr), size(0) {}
};

struct RetExtensionAbilityInfoV2 {
    char* bundleName;
    char* moduleName;
    char* name;
    uint32_t labelId;
    uint32_t descriptionId;
    uint32_t iconId;
    bool exported;
    int32_t extensionAbilityType;
    CArrString permissions;
    RetApplicationInfoV2 applicationInfo;
    CArrMetadata metadata;
    bool enabled;
    char* readPermission;
    char* writePermission;
    char* extensionAbilityTypeName;
    RetCArrSkill skills;
    int32_t appIndex;

    RetExtensionAbilityInfoV2()
        : bundleName(nullptr), moduleName(nullptr), name(nullptr), labelId(0), descriptionId(0), iconId(0),
          extensionAbilityType(0), enabled(false), readPermission(nullptr), writePermission(nullptr),
          extensionAbilityTypeName(nullptr), appIndex(0)
    {}
};

struct CArrRetExtensionAbilityInfoV2 {
    RetExtensionAbilityInfoV2* head;
    int64_t size;

    CArrRetExtensionAbilityInfoV2() : head(nullptr), size(0) {}
};

struct RetPreloadItem {
    char* moduleName;

    RetPreloadItem() : moduleName(nullptr) {}
};

struct CArrRetPreloadItem {
    RetPreloadItem* head;
    int64_t size;

    CArrRetPreloadItem() : head(nullptr), size(0) {}
};

struct RetDependency {
    char* bundleName;
    char* moduleName;
    uint32_t versionCode;

    RetDependency() : bundleName(nullptr), moduleName(nullptr), versionCode(0) {}
};

struct CArrRetDependency {
    RetDependency* head;
    int64_t size;

    CArrRetDependency() : head(nullptr), size(0) {}
};

struct CDataItem {
    char* key;
    char* value;

    CDataItem() : key(nullptr), value(nullptr) {}
};

struct CArrDataItem {
    CDataItem* head;
    int64_t size;

    CArrDataItem() : head(nullptr), size(0) {}
};

struct CRouterItem {
    char* name;
    char* pageSourceFile;
    char* buildFunction;
    CArrDataItem data;
    char* customData;

    CRouterItem() : name(nullptr), pageSourceFile(nullptr), buildFunction(nullptr), data(), customData(nullptr) {}
};

struct CArrRouterItem {
    CRouterItem* head;
    int64_t size;

    CArrRouterItem() : head(nullptr), size(0) {}
};

struct RetHapModuleInfoV2 {
    char* name;
    char* icon;
    uint32_t iconId;
    char* label;
    uint32_t labelId;
    char* description;
    uint32_t descriptionId;
    char* mainElementName;
    CArrRetAbilityInfoV2 abilitiesInfo;
    CArrRetExtensionAbilityInfoV2 extensionAbilitiesInfo;
    CArrMetadata metadata;
    CArrString deviceTypes;
    bool installationFree;
    char* hashValue;
    int32_t moduleType;
    CArrRetPreloadItem preloads;
    CArrRetDependency dependencies;
    char* fileContextMenuConfig;
    CArrRouterItem routerMap;
    char* codePath;
    char* nativeLibraryPath;

    RetHapModuleInfoV2()
        : name(nullptr), icon(nullptr), iconId(0), label(nullptr), labelId(0), description(nullptr), descriptionId(0),
          mainElementName(nullptr), installationFree(false), hashValue(nullptr), moduleType(0),
          fileContextMenuConfig(nullptr), codePath(nullptr), nativeLibraryPath(nullptr)
    {}
};
} // namespace Platform
} // namespace AbilityRuntime
} // namespace Keels

#endif // OHOS_ABILITY_RUNTIME_CJ_BUNDLE_INFO_H